﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Supervise_TraContractCheck : System.Web.UI.Page
{
    string ProjectId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            if (_Account != null)
            {
                ProjectId = SysFun.IsSQL(Request.QueryString["ProjectId"]);              
                BindData();
            }
        }
    }
    private void BindData()
    {
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "PurchaseTable";                  //要查询的表明     
        dbPage.SelectField = " CompanyName_TB,GoodsId,ProductName,GoodsName,MedicineModel,Outlookc,Factor,IsNull(Unit,'')+'/'+IsNull(PackUnit,'') As Pack1,CASE QualityLevels " + ConfigurationManager.AppSettings["QualityLevels"].ToString() + " END AS QualityLevels,PurchasePrice,accountid_sc,UserCode_SC,CompanyName_SC,CompanyName_TB,UserCode_TB,HospitalName,accountid_ps,UserCode_PS,CompanyName_PS,BidPrice,PlanPurNum,convert(numeric(30,2),BidPrice*PlanPurNum) as PlanPrice ";//要显示的字段
        dbPage.Key = "HsPId";                                               //表的主键    
        dbPage.Where = " State='正常采购' and projectid=" + ProjectId;                                           //查询条件    
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);         //要显示第几页   
        dbPage.PageSize = 20;                                                    //没有显示记录条数   
        dbPage.OrderBy = " AccountId_YY,Accountid_PS";//排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        db.Close();
        DbPageFlip1.DbPage = dbPage;//将数据传给控键
    }
}
